import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xvideos/hj_model/video_model.dart';
import 'package:xvideos/hj_page/user_center_page/user_center_page.dart';
import 'package:xvideos/tools_base/widget/net_image_widget.dart';

class UserAvatar extends StatelessWidget {
  final double size;
  final bool showVip;
  final Publisher? model;
  final bool isCircle;
  final double? bigVsize;
  final bool showBorder;
  final GestureTapCallback? onTap;
  const UserAvatar({
    super.key,
    this.size = 52,
    this.showVip = false,
    this.model,
    this.isCircle = true,
    this.bigVsize,
    this.showBorder = false,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: size,
      height: size,
      decoration: BoxDecoration(
          border: showBorder ? Border.all(color: Color(0xffDB361F), width: 2) : null, borderRadius: BorderRadius.circular(100)),
      child: Stack(
        alignment: Alignment.center,
        children: [
          GestureDetector(
            onTap: onTap ?? () {
              Get.toNamed(UserCenterPage.routeName, arguments: {'uid': model?.uid ?? 0}, preventDuplicates: false);
            },
            child: NetworkImageLoader(
              imageUrl: model?.portrait ?? '',
              width: size - (showBorder ? 4 : 0),
              height: size - (showBorder ? 4 : 0),
              borderRadius: isCircle ? size / 2 : 0,
            ),
          ),
        ],
      ),
    );
  }
}
